<?php

class SharingLogTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\SharingLog\SharingLogClass();
		$class['user_id'] = $this->testNum();
		$class['share_num'] = $this->testNum();
		$class['that_day'] = $this->testStr();
		$class['share_goals'] = $this->testNum();
		$class['title'] = $this->testStr();
		$class['desc'] = $this->testStr();
		$class['link'] = $this->testStr();
		$class['imgUrl'] = $this->testStr();


        $class->insert();
        $result_class = new \Orm\SharingLog\SharingLogClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['user_id'],$result_class['user_id']);
		$this->assertEquals($class['share_num'],$result_class['share_num']);
		$this->assertEquals($class['that_day'],$result_class['that_day']);
		$this->assertEquals($class['share_goals'],$result_class['share_goals']);
		$this->assertEquals($class['title'],$result_class['title']);
		$this->assertEquals($class['desc'],$result_class['desc']);
		$this->assertEquals($class['link'],$result_class['link']);
		$this->assertEquals($class['imgUrl'],$result_class['imgUrl']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['user_id'] = $this->testNum();
		$class['share_num'] = $this->testNum();
		$class['that_day'] = $this->testStr();
		$class['share_goals'] = $this->testNum();
		$class['title'] = $this->testStr();
		$class['desc'] = $this->testStr();
		$class['link'] = $this->testStr();
		$class['imgUrl'] = $this->testStr();


        $class->update();
        $result_class = new \Orm\SharingLog\SharingLogClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['user_id'],$result_class['user_id']);
		$this->assertEquals($class['share_num'],$result_class['share_num']);
		$this->assertEquals($class['that_day'],$result_class['that_day']);
		$this->assertEquals($class['share_goals'],$result_class['share_goals']);
		$this->assertEquals($class['title'],$result_class['title']);
		$this->assertEquals($class['desc'],$result_class['desc']);
		$this->assertEquals($class['link'],$result_class['link']);
		$this->assertEquals($class['imgUrl'],$result_class['imgUrl']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\SharingLog\SharingLogClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}